using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Moq;
using NUnit.Framework;
using RFS.BizLogic;
using RFS.BizLogic.PaiShi.Accounting;
using RFS.BizLogic.PaiShi.Impl;
using RFS.BizLogic.PaiShi.Ports;
using RFS.BizLogic.Sys;
using RFS.Domain.PaiShi;
using RFS.Domain.PaiShi.WorkFlow;
using RFS.WPF.StartUp;
using RFS.WPF.Views;
using ycx;

namespace TestWPF2.PaiShi
{
    public class TVoucherSetVm
    {
        private IAntiObject _en;


        [SetUp]
        public void setup()
        {
            _en = ViewStarter.Start(true);
            Moqa(_en);
        }
        
        
        private void Moqa(IAntiObject antiObject)
        {
            #region moq prod

            IProductPriceItem priceItem =new ProductPriceItem(){ DateTime = DateTime.Today,
                Price = (decimal)1.1 ,
                Product = new Product("1","tp","45"),
                Supplier = "s1"
            };
            var pm = new Mock<IPriceManagerPort>();
            pm.Setup(x => x.GetPrice(
                    It.IsAny<DateTime>()
                    , It.IsAny<IProduct>(),
                    // It.IsAny<string>(),
                    // It.IsAny<int>(),
                    It.IsAny<bool>()
                )
            ).Returns(priceItem);
            
            antiObject.RegisterMock4Test(pm.Object);
            

            #endregion
            
        }



        [Test]
        public void T01_CreateAVSvm_returna()
        {
            var vm= _en.Get<VoucherSetWrapperVm>();
            
            Thread.Sleep(1000);
            Assert.IsNotNull(vm.DO);
            
            vm.Vouchers.Echo();
            

            // vm.CurrentVoucher.LoadLeftNode();
            vm.CmdCheckAndCreateVouchers.Execute();
        }
        
         
        [Test]
        public void T01_LoadData__returnVs()
        {
            var vm= _en.Get<VoucherSetWrapperVm>();
            
            Thread.Sleep(1000);
            Assert.IsNotNull(vm.DO);
            
            
            vm.CmdLoadData.Execute();

            Assert.IsTrue(vm.LeftSet.Count > 0);
            
        }
                 
        [Test]
        public void T01_Check4Vs__returnVs()
        {
            var vm= _en.Get<VoucherSetWrapperVm>();
            
            Thread.Sleep(1000);
            Assert.IsNotNull(vm.DO);
            
            
            vm.CmdLoadData.Execute();
            vm.CmdCheckAndCreateVouchers.Execute();

            Assert.IsTrue(vm.LeftSet.Count > 0);
            
            vm.Vouchers.Echo();
            
            
            
        }
        
         
 
        
    }
}